<?php $post = $this->get('post');?>
<form method="post" action="<?php _actionUrl($this)?>" onsubmit="return ajax_form(this)">
<input type="hidden" name="ID" value="<?php _e($post['ID'])?>"/>
<div class="x-list-title"> 
<table height="100%" width="100%" border="0" cellpadding="0">
<tr><td>
<h2>Công việc mới</h2>
</td></tr></table>
</div>
<div class="x-form-container">
<table width="100%" border="0" cellpadding="0" class="x-form">
<tr class="row-message">
	<td colspan="2">
		<div class="form-message"><?php $this->e('message');?></div>
	</td>
</tr>
<tr>
	<td class="x-form-label">
		Tiêu đề: 
	</td>
	<td class="x-form-input">
		<input type="text" name="title" style="width:300px" class="x-text" value="<?php _e($post['title']);?>"/>
	</td>
</tr>
<tr>
	<td class="x-form-label">
		Số ngày thực hiện: 
	</td>
	<td class="x-form-input">
		<input type="number" name="dateof" min="0" style="width:100px" class="x-text" step="0.5" value="<?php _e($post['dateof']);?>"/>
	</td>
</tr>
<?php if( count($this->get('projects')) > 0 ):?>
<tr>
	<td class="x-form-label">
		Dự án: 
	</td>
	<td class="x-form-input">
		<select name="project_id" class="x-select" style="min-width:150px">
		<option value=''></option>
		<?php foreach( $this->get('projects') as $project ):?>
			<option value="<?php _e($project['ID']);?>"<?php _e( $project['selected'] ? ' selected':'')?>><?php _e($project['title']);?></option>
		<?php endforeach;?>	
		</select>
	</td>
</tr>
<?php endif;?>
<tr>
	<td class="x-form-label">
		Loại công việc: 
	</td>
	<td class="x-form-input">
		<select name="parent_id" class="x-select" style="min-width:150px">
		<option value=''></option>
		<?php foreach( $this->get('types') as $t ):?>
			<option value="<?php _e($t['ID']);?>"<?php _e( $t['selected'] ? ' selected':'')?>><?php _e($t['title']);?></option>
		<?php endforeach;?>	
		</select>
	</td>
</tr>
<tr>	
	<td class="x-form-label">
		Thời gian: 
	</td>
	<td class="x-form-input">
		<input type="text" autocomplete="off" name="time_start" value="08:00" onclick="time_picker(this)" class="x-text x-time"/> 
		<input type="text" title="Kết thúc" name="date_start" onclick="date_picker(this,{format: 'd/m/Y' })" value="<?php _e(date("d/m/Y"));?>" class="x-text x-date"/>
		 đến <input type="text" autocomplete="off" name="time_end" value="<?php if( $post['date_end'] ) _e( date("H:i",strtotime($post['date_end'])) );?>" onclick="time_picker(this)" class="x-text x-time"/>
		<input type="text" title="Kết thúc" name="date_end" onclick="date_picker(this,{format: 'd/m/Y' })" value="<?php if( $post['date_end'] ) _e(date("d/m/Y",strtotime($post['date_end'])));?>" class="x-text x-date"/>
	</td>
</tr>
<tr>	
	<td class="x-form-label">
		Trạng thái:
	</td>
	<td class="x-form-input">
		<select name="status" class="x-select">
			<option value="active" checked><?php _e(get_status('active'))?></option>	
			<option value="inactive"><?php _e(get_status('inactive'))?></option>	
			<option value="complete"><?php _e(get_status('complete'))?></option>	
			<option value="cancel"<?php _e($post['status']=='cancel' ? ' selected':'')?>><?php _e(get_status('cancel'))?></option>
		</select>	
	</td>
</tr>
<tr>	
	<td class="x-form-label">
		Tiến độ:
	</td>
	<td class="x-form-input">
		<input type="text" size="3" name="rate" onclick="status_picker(this)" value="<?php _e($post['rate'])?>" class="x-text x-status"/> %
	</td>
</tr>
<tr>	
	<td class="x-form-label">
		Người tạo:
	</td>
	<td class="x-form-input">
	<?php _e( get_user_link($this->get('user')));?>
	</td>
</tr>
<?php $users = $this->get('users');?>
<tr>	
	<td class="x-form-label">
		Người thực hiện:
	</td>
	<td class="x-form-input">
		<div class="x-select-users" x-name="implement[]" x-title="Người thực hiện">
		<?php foreach( $users as $u ):?>
		<?php if( $u['is_implement'] == 'yes' ):?>
		<span class="item">
			<input type="hidden" name="implement[]" value="<?php _e($u['ID'])?>"><a><?php _e($u['username'])?></a><span class="close">x</span>
		</span>
		<?php endif;?>
		<?php endforeach;?>	
		</div>
	</td>
</tr>
<tr>	
	<td class="x-form-label">
		Cho phép xem:
	</td>
	<td class="x-form-input">
		<div class="x-select-users" x-name="guest[]" x-title="Cho phép xem">
		<?php foreach( $users as $u ):?>
		<?php if( $u['is_guest'] == 'yes' ):?>
		<span class="item">
			<input type="hidden" name="guest[]" value="<?php _e($u['ID'])?>"><a><?php _e($u['username'])?></a><span class="close">x</span>
		</span>
		<?php endif;?>
		<?php endforeach;?>	
		</div>
	</td>
</tr>
<tr>
	<td class="x-form-label">Mức ưu tiên:</td>
	<td class="x-form-input">
		<input type="radio" name="priority" value="0"/> <span class="p-low">Thấp</span>
		<input type="radio" name="priority" value="1" checked> <span class="p-normal">Bình thường</span>
		<input type="radio" name="priority" value="2"/> <span class="p-hight">Cao</span>
	</td>
</tr>
<tr>
	<td class="x-form-label">
		Mô tả:
	</td>
	<td class="x-form-input">
		<textarea name="desc" class="x-text x-editor" style="width:609px;height:200px"><?php _e($post['desc']);?></textarea>
	</td>
</tr>
<tr>
	<td class="x-form-label" align="center" valign="top">
		<span class="x-attachment"></span>
	</td>
	<td class="x-form-input" valign="top">
		<?php foreach( $this->get('files') as $file ):?>
		<div class='x-file-info'>
			<input checked type='checkbox' name='files[]' value='<?php _e($file['ID']);?>'/>
			<a href="<?php _ctrUrl($this);?>/File?ID=<?php _e($file['ID']);?>" target="_blank"><?php _e($file['filename']);?> <?php _e($file['size']);?> KB	</a>
		</div>
		<?php endforeach;?>
		<div class="x-files" url="<?php _baseUrl();?>/Task/Index/Upload?ID=<?php _e($post['ID'])?>"></div>
	</td>
</tr>
<tr>
	<td></td>
	<td>
		<?php _e(tpl_button_add('Cập nhật'));?>
		<a class="x-button x-fresh" href="#Task">Hủy bỏ</a>		
	</td>
</tr>
</table></div>
</form>